package priv.cwr.springboot.demo.model.db;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * 用户实体
 * User: R
 * Date: 2018/8/29
 * Time: 11:00
 * Created with IntelliJ IDEA.
 */
@Data
@Table(name = "t_user")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserEntity {
    @Id
    @GeneratedValue(generator = "JDBC")
    @JsonProperty("user_id")
    @Column(name = "user_id")
    @Range(min = 1, max = 99999999999L, message = "{User.Range.userId}")
    @ApiModelProperty("用户id")
    private Long userId;

    @JsonProperty("dept_id")
    @Column(name = "dept_id")
    @Range(min = 1, max = 99999999999L, message = "{User.Range.deptId}")
    @ApiModelProperty("部门id")
    private Long deptId;

    @NotBlank(message = "{User.NotBlank.name}")
    @ApiModelProperty("用户名称")
    private String name;

    @NotBlank(message = "{User.NotBlank.phone}")
    @ApiModelProperty("电话")
    private String phone;

    @ApiModelProperty("用户介绍")
    private String introduce;

    @JsonProperty("create_time")
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("创建时间")
    private Date createTime;

    @JsonProperty("update_time")
    @Column(name = "update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("最近修改时间")
    private Date updateTime;
}
